package client;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;

public class Obstacle {
	private Rectangle boundingRect;
	private Image image;

	public boolean checkCollisions(Rectangle p) {
		boolean collide = false;
		if (boundingRect.intersects(p)) {
			collide = true;
		}
		return collide;
	}

	public Rectangle getBoundingRect() {
		return boundingRect;
	}

	public void setBoundingRect(Rectangle boundingRect) {
		this.boundingRect = boundingRect;
	}

	public Image getImage() {
		return image;
	}

	public void setImage(Image image) {
		this.image = image;
	}

	public void paint(Graphics g) {
		if (image != null) {
			for (int x = 0; x < boundingRect.width; x += image.getWidth(null)) {
				for (int y = 0; y < boundingRect.height; y += image
						.getHeight(null)) {
					g.drawImage(image, x + boundingRect.x, y + boundingRect.y,
							null);
				}
			}
		} else {
			g.setColor(Color.BLACK);
			g.drawRect(boundingRect.x, boundingRect.y, boundingRect.x
					+ boundingRect.width, boundingRect.y + boundingRect.height);
		}
	}
}
